package com.wteam.controller;

import com.wteam.PoJo.DTO.coupon;
import com.wteam.PoJo.VO.couponVo;
import com.wteam.service.CouponService;
import com.wteam.untils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@Api(tags = "促销活动接口")
@RequestMapping("/coupon")

public class CouponController {

    @Autowired
    private CouponService couponService;

    /**
     *
     * @param coupon
     * @return
     */
    @ApiOperation(value = "发促销活动1")
    @PostMapping("/saveaction")
    public Result SaveCoupon(@RequestBody couponVo coupon) {
        return couponService.save(coupon);
    }

    /**
     *
     * @param page
     * @param pagesize
     * @return
     */
    @ApiOperation(value = "查看促销活动")
    @PostMapping("/listaction/{page}/{pagesize}")
    public Result<List<coupon>> listCopon(@PathVariable Integer page, @PathVariable Integer pagesize) {
        return couponService.listConpon(page, pagesize);
    }

    /**
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "用户积分换优惠卷")
    @ApiImplicitParam(name = "id", value = "优惠卷id")
    @PutMapping("/{id}")
    public Result UserGetCopon(@PathVariable Integer id) {
        return couponService.UserGetCopon(id);
    }


}
